var ns;
var app = new Vue({
    el: '#app',
    data: {
        form: {
            ID:0,
            MemberName: '',
            MemberPhone: '',
            WorkTime: '',
            MemberBrief: '',
            PhotoPath: '',
            IsDZ: false,
            IsTC: false,
            DzNumber:0,
            TcNumber:0,
            CommentList:[]
        }
    },
    methods: {
        get_data: function() {
            var that = this;
            var options = {};
            options.action = 'gethousekeeperdetail';
            options.ID = that.form.ID;
            ns.post(options, function(succeed, data, err) {
                console.log(JSON.stringify(data));
                if (succeed) {
                    that.form.MemberName=data.data.MemberName,
                    that.form.MemberPhone=data.data.MemberPhone,
                    that.form.WorkTime=data.data.WorkTime,
                    that.form.MemberBrief=data.data.MemberBrief,
                    that.form.PhotoPath=data.data.PhotoPath,
                    that.form.IsDZ=data.data.IsDZ,
                    that.form.IsTC=data.data.IsTC,
                    that.form.DzNumber=data.data.DzNumber,
                    that.form.TcNumber=data.data.TcNumber,
                    that.form.CommentList=data.data.CommentList
                } else if (err) {
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            }, {
                toast: true
            });
        },
        do_open_more:function(){
            var that=this;
            ns.openWin('butler_pingjialist','业主之声',{
                ID:that.form.ID
            });
        },
        do_write_pingjia:function(typeid){
            var that=this;
            var options = {};
            options.action = 'ishousekeeperusercomment';
            options.HouseKeeperID = that.form.ID;
            ns.post(options, function(succeed, data, err){
                console.log(JSON.stringify(succeed));
                console.log(JSON.stringify(data));
                if(data.status){
                    api.openFrame({
                        name: 'butler_dianzan',
                        url: './butler_dianzan.html',
                        rect: {
                                x:0,
                                y:0,
                                w:api.winWidth,
                                h:api.winHeight
                        },
                        pageParam:{
                            Type:typeid,
                            HouseKeeperID:that.form.ID
                        },
                        bgColor: 'rgba(0,0,0,0.6)',
                        bounces: false
                     });

                }else{
                    api.toast({
                        msg: data.Msg,
                        duration: 2000,
                        location: 'bottom'
                    });
                }

            });
            
        }
    }
});
apiready = function() {
    api.parseTapmode();
    ns = window.Foresight.Util;
    app.form.ID = api.pageParam.ID;
    app.get_data();
    api.addEventListener({
        name: 'updatabutler'
    }, function() {
        console.log(111);
        setTimeout(function() {
            console.log(222);
            app.get_data();
        }, 500);
    });
};